package br.ykhan.t5.ytools.menu.services;

import java.util.Collection;

import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.InjectService;
import org.apache.tapestry5.services.LibraryMapping;

public class MenuModule
{
	public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
	{
		configuration.add(new LibraryMapping("ymenu", "br.ykhan.t5.ytools.menu"));
	}
	
	// Services
	
	public static void bind(ServiceBinder binder)
	{
		// Core Services
		binder.bind(MenuSource.class, DefaultMenuSource.class);
		binder.bind(MenuBuilder.class, DefaultMenuBuilder.class);

		// Utilities
		binder.bind(PathPatternsMatcher.class, URIPatternsMatcher.class);
	}
	
	
	public static void contributeIgnoredPathsForMenu(Configuration<String> configuration)
	{
		configuration.add("core/*");
	}
	
	public static IgnoredPathsForMenu buildIgnoredPathsForMenu(Collection<String> configuration, @InjectService("PathPatternsMatcher") PathPatternsMatcher patternsMatcher)
	{
		return new IgnoredPathsForMenuImpl(configuration, patternsMatcher);
	}
}
